<!doctype html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>见闻间</title>
    <link rel="stylesheet" href="/install/css/ixx.css" />
</head>

<body>
    <div id="ixx2" class="container">
        <div class="content">
            <div class="content-img">
                <video class="bg" src="/install/img/1.mp4" autoplay loop muted :controls="false"
                    :show-center-play-btn="false" object-fit="cover">
                </video>
                <div class="name">
                    见闻间 - 让社区以全新的方式喧起来<br>
                    官网：https://cc.chaopin100.com/#/xinxuan<br>
                    Copyright © 2024 Supengjun. All Rights Reserved. 陕西超拼软件科技有限公司 版权所有
                </div>
            </div>
            <div class="content-box">
                <div class="t3">数据库信息配置</div>
                <div class="box-sp" style="margin-top: 10px;">
                    <div class="input-box">
                        <div class="input">
                            <div class="table">服务器地址</div>
                            <input placeholder="请填写" v-model="formData.mysql.host" />
                        </div>
                        <div class="input-tips">数据库服务器地址，一般为127.0.0.1</div>
                    </div>
                    <div class="input-box">
                        <div class="input">
                            <div class="table">服务器端口</div>
                            <input placeholder="请填写" v-model="formData.mysql.port" />
                        </div>
                        <div class="input-tips">数据库服务器端口，一般为3306</div>
                    </div>
                </div>
                <div class="box-sp">
                    <div class="input-box">
                        <div class="input">
                            <div class="table">用户名</div>
                            <input placeholder="请填写" v-model="formData.mysql.username" />
                        </div>
                        <div class="input-tips">数据库用户名</div>
                    </div>
                    <div class="input-box">
                        <div class="input">
                            <div class="table">密码</div>
                            <input placeholder="请填写" v-model="formData.mysql.password" />
                        </div>
                        <div class="input-tips">数据库密码</div>
                    </div>
                </div>
                <div class="input-box">
                    <div class="input">
                        <div class="table">名称</div>
                        <input placeholder="请填写" v-model="formData.mysql.database" />
                    </div>
                    <div class="input-tips">建议使用默认即可</div>
                </div>
                <div class="t3" style="margin-top: 10px;">redis信息配置</div>
                <div class="box-sp" style="margin-top: 10px;">
                    <div class="input-box">
                        <div class="input">
                            <div class="table">服务器地址</div>
                            <input placeholder="请填写" v-model="formData.redis.host" />
                        </div>
                        <div class="input-tips">redis服务器地址，一般为127.0.0.1</div>
                    </div>
                    <div class="input-box">
                        <div class="input">
                            <div class="table">服务器端口</div>
                            <input placeholder="请填写" v-model="formData.redis.port" />
                        </div>
                        <div class="input-tips">redis端口，一般为6379</div>
                    </div>
                </div>
                <div class="input-box">
                    <div class="input">
                        <div class="table">密码</div>
                        <input placeholder="请填写" v-model="formData.redis.password" />
                    </div>
                    <div class="input-tips">redis数据库密码</div>
                </div>
                <div class="btn abg" @click="confirmInstal">确认安装</div>
            </div>
        </div>
    </div>
</body>
<script src="/install/js/vue2.6.11.js"></script>
<script src="/install/js/vue-toasted.min.js"></script>
<script src="/install/js/axios.min.js"></script>
<script>
    Vue.use(Toasted)
    new Vue({
        el: '#ixx2',
        data() {
            return {
                formData: {
                    mysql: {
                        host: '127.0.0.1',
                        port: 3306,
                        username: 'root',
                        password: '',
                        database: 'xinxuan'
                    },
                    redis: {
                        host: '127.0.0.1',
                        port: 6379,
                        password: ''
                    }
                }
            }
        },
        methods: {
            async confirmInstal() {
                const res = await this.verifyForm();
                if (!res) {
                    return false;
                }
                window.location.href = "/install/index?step=3";
            },
            async verifyForm() {
                console.log('verify');
                const res = await axios({
                    method: 'post',
                    url: '/install/index/verify',
                    data: {
                        ...this.formData
                    }
                });
                let { data, msg, error } = res.data;
                if (error != 0) {

                    this.$toasted.show(msg, { type: 'error', position: 'top-center', duration: 5000 })
                    return false;
                }
                return true;

            }
        }
    })
</script>

</html>